<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input class="a" type="text" /> 
    <select class="mytype">
        <option value="+">+</option>
        <option value="-">-</option>
        <option value="*">*</option>
        <option value="/">/</option>
    </select>
    <input class="b" type="text" /> = <input class="res" type="text" /> 
    <button class="btn">计算结果</button>
    <script>
    // 1.输入年份判断改年是平年还是闰年
    // var year = prompt("请输入年份");
    // if((year%4==0 && year%100!=0) || year%400==0){
    //     console.log("是闰年");
    // }else{
    //     console.log("是平年")
    // }

    // 2.计算两个文本框的加减乘除
    var btn = document.getElementsByClassName("btn")[0];
    var aEle = document.getElementsByClassName("a")[0];
    var bEle = document.getElementsByClassName("b")[0];
    var typeEle = document.getElementsByClassName("mytype")[0];
    var resEle = document.getElementsByClassName("res")[0];
    btn.onclick = function(){
        // aEle.value = "123";
        var a = parseInt( aEle.value);
        var b = parseInt( bEle.value);
        var type = typeEle.value;
        // console.log(a,b,type);
        // console.log(typeof a);

        if(type=="+"){
            var res =  a + b;
        }else if(type=="-"){
            var res = a - b;
        }else if(type=="*"){
            var res = a * b;
        }else{
            var res = a/b;
        }
        console.log(res);
        resEle.value = res;
        // var res = a type b
    }

    </script>
</body>
</html>